package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.user;
import com.example.demo.entity.user1;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface userMapper<String>{
    @Select("select * " +
            "from view_user " +
            "where username=#{username} " +
            "and password=#{password}")
    public user1 log(String username, String password);

    @Insert("insert into view_user value(#{username},#{password},#{permissions},#{name},#{role},#{remark})")
    public int register(user user);

    @Select("select * from view_user where username=#{username}")
    public user SelectUsername(String username);

    @Select("select * from view_user ")
    public List<user> query();

    @Delete("delete from view_user where username=#{username} and password=#{password}")
    public int delete(String username,String password);

    @Update("update view_user set password=#{NewPassword} " +
            "where username=#{username} and password=#{OldPassword}")
    public int change(String NewPassword,String username,String OldPassword);

    @Update("update view_user set password=#{password},permissions=#{permissions}," +
            "name=#{name},role=#{role},remark=#{remark} " +
            "where username=#{username}")
    public int update(user user);
}
